<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Requests;
use Illuminate\Support\Facades\Input;
use App\Http\Controllers\controller;

class CommonController extends Controller
{
    public function upload(){
    	//获取上传的缩略图的信息
    	$file = Input::file('Filedata');
    	//判断文件是否有效
    	if($file->isValid()){
    		//获取上传文件的后缀
    		$entension = $file -> getClientOriginalExtension();
    		//新文件的文件名 日期+随机数
    		$newName = date('YmdHis').mt_rand(100,999).'.'.$entension;
    		//文件移动之后进行重命名
    		$path = $file->move(base_path().'/uploads',$newName);
    		//文件的简短路径 
    		$filepath = 'uploads/'.$newName;
            return $filepath;
    	}
    }
}
